package com.hushow.demo.process;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
//@EnableBatchProcessing
public class MyBatchConfiguration {

    @Autowired
    public JobBuilderFactory jobBuilderFactory;

    @Autowired
    public StepBuilderFactory stepBuilderFactory;

    @Bean
    public Job encodeVideoJob(MyJobCompletionNotificationListener listener, Step step1) {
//        return jobBuilderFactory.get("encodeVideoJob")
//                .incrementer(new RunIdIncrementer())
//                .listener(listener)
//                .flow(step1)
//                .end()
//                .build();

        return jobBuilderFactory.get("encodeVideoJob")
                .start(step1)
                .build();
    }

    @Bean
    public Step encodeVideo(MyItemWriter writer, MyItemReader reader, MyPersonItemProcessor processor) {
        return stepBuilderFactory.get("encodeVideo")
                .<MyPerson, MyPerson> chunk(1)
                .reader(reader)
                .processor(processor)
                .writer(writer)
                .build();
    }


}